<?php
namespace App\Libraries\Tools;


use App\Models\User\User;

class URL
{

    static private $oss_http = 'https://';
    static private $oss_endpoint = '.oss-cn-shanghai.aliyuncs.com/';
    static private $oss_url = 'http://beboy.oss-cn-shanghai.aliyuncs.com/';

    /**
     * 获取用户头像URL
     * @param $user_id
     * @return string
     */
    static public function getAvatarURL($user_id){
        $user = User::where('user_id', $user_id)->first();
        if(empty($user) || empty($user->cover)){
            return '';
        }
        return self::$oss_http.env('ALIYUN_BUCKET').self::$oss_endpoint.$user->cover;
    }

    /**
     * 获取商品图片URL
     * @param $file
     * @return string
     */
    static public function getProductPic($file){
        return self::$oss_http.env('ALIYUN_BUCKET').self::$oss_endpoint.$file;
    }

    /**
     * 获取商家图片URL
     * @param $shop_id
     * @param $file_id
     * @return string
     */
    static public function getShopPic($shop_id, $file_id){
        return '';
    }

    /**
     * 获取图片URL
     * @param $file
     * @return string
     */
    static public function getImage($file){
        if(empty($file)){
            return '';
        }
        return self::$oss_http.env('ALIYUN_BUCKET').self::$oss_endpoint.$file;
    }
}